package com.unionpay.upyzt.spring.example.entity;

import com.unionpay.upyzt.Upyzt;
import com.unionpay.upyzt.exception.InvalidRequestException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Incoming {
    private String memberCode;
    private String memberName;
    private IdCard idCard;
    private SettleAcct settleAcct;

    private String outRequestNo;

    private String mobileNumber;

    private String smsCode;

    private String password;

    private String bankAddress;


    public Map<String,Object> toMap(){
        Map<String, Object> params = new HashMap<>();
        params.put("out_request_no",this.outRequestNo);
        params.put("id_card", this.idCard.toMap());
        try {
            params.put("mobile_number", Upyzt.encryptField(this.mobileNumber));
            params.put("password", Upyzt.encryptField(this.password));
        } catch (InvalidRequestException e) {
            throw new RuntimeException(e);
        }
        params.put("settle_acct", this.settleAcct.toMap());
        params.put("sms_code", this.smsCode);
        return params;
    }
}
